#!/bin/bash
#
# Insert an atom
#
# Call with 
#
# gsas_constrain_diffuse_scattering <parameter> <constraint string>
#
# where atom string is the information needed by GSAS to add an atom
#

# echo the call so we can see what's going on
echo "$0 $1 $2 $3 $4 $5 $6"

# Check syntax
if [ "$1" = "" ]; then
	echo "$0 called without a parameter to be constrained (A, R, or U)."
	read -p "This will go wrong - maybe you should break here with Ctrl-C..."
	exit 0
fi

if [ "$2" = "" ]; then
	echo "$0 called without a constraint term (term, histograms, value)!"
	read -p "This will go wrong - maybe you should break here with Ctrl-C..."
	exit 0
fi


# Add the atom
echo "k l o d" > temp.txt
echo "k" >> temp.txt
echo "$1" >> temp.txt
echo "i" >> temp.txt
echo "$2 $3 $4 $5 $6 $7 $8 $9" >> temp.txt
echo " " >> temp.txt
echo "x" >> temp.txt
echo "x" >> temp.txt
echo "x" >> temp.txt
echo "x" >> temp.txt
echo "x" >> temp.txt

expedt `cat GSAS_EXP` < temp.txt > out.txt

echo "Constrained diffuse scattering term for parameter $1 with constraint strings $2 $3 $4 $5 $6 $7 $8 $9.\newline" >> `cat GSAS_EXP`.tex



